home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-22 | 3.9 KB | 83 lines | [TEXT/X_#a] |
- ; Tutorial 7: Intro to 3D
-
- animate 40 ; this file defines a 40-frame animation
-
- ; XModels-3D is very similar to xModels-2D, except that it
- ; deals with three-dimensional objects instead of two-dimensional.
- ; In xModels-2D, there is an x-axis that crosses the screen
- ; horizontally from left to right and a y-axis that extends
- ; vertically from bottom to top. xModels-3D has also has these,
- ; but it adds a third axis, called the z-axis. Each point
- ; now has three coordinates. The origin, at the center of
- ; the drawing window, is the point (0,0,0). Points with
- ; negative z-values lie behind the screen; points with z = 0
- ; lie on the screen; and points with positive z-values lie
- ; in front of the screen. The z-axis is perpendicular to the
- ; screen and passes through the point (0,0,0). The screen
- ; itself is referred to as the "xy-plane".
- ;
- ; You can use the basic objects "circle", "square" and "line"
- ; in xModels-3D. These objects lie in the xy-plane but can
- ; now be rotated or translated out of that plane. You can
- ; have ordinary two-dimensional polygons, constructed from
- ; PAIRS of coordinates, just as in xModels-2D. (Note:
- ; xModels-3D does NOT have filled in versions of these objects,
- ; such as graycircle and blackpolygon.) You can also
- ; have "three-dimensional polygons." Each vertex of a
- ; three-dimensional polygon has THREE coordinates. The command
- ; for making a three-dimensional polygon is "polygon3D". Here
- ; for example are two rectangles defined as 3D polygons:
-
- polygon3D -7,-7,-22 7,-7,-22 7,-7,22 -7,-7,22
- polygon3D -7,7,-22 7,7,-22 7,7,22 -7,7,22
-
- ; xModels-3D has one additional basic object, called "cube".
- ; This represents a 1-by-1-by-1 cube centered at the point
- ; (0,0,0).
- ;
- ; There are, of course, differences between transformation in
- ; two dimensions and transformations in three dimensions. For
- ; example, the "translate" command now takes three parameters,
- ; and thre is a "ztranslate" command. Transformations will
- ; be covered in the next Tutorial, but here is an example of
- ; a group of moving cubes:
-
- cube scale 4 zrotate 0:180 ztranslate -20:20
- cube scale 4 translate 5,5,-20:20
- cube scale 4 translate 5,-5,-20:20
- cube scale 4 translate -5,5,-20:20
- cube scale 4 translate -5,-5,-20:20
-
- ; The middle cube rotates about the z-axis as it moves.
- ; It might not be obvious, but these cubes fit nicely between
- ; the two rectangles defined above. If you render this, you
- ; will see the cubes move forward from the back of the
- ; rectangles to the front. By the end of the animation,
- ; though, you won't see the cubes because they have moved
- ; "behind" your viewpoint. You also won't see the front ends
- ; of the rectangles. The brings us to the topic of "three-
- ; dimensional viewing" and the View Menu.
- ;
- ; Since the computer screen is two-dimensional, a three-
- ; dimensional image has to be "projected" onto the screen.
- ; Think of a light source casting a shadow of the objects
- ; onto the screen. The View Menu controls where that light
- ; source is placed. By default, it is a point source
- ; located at the point (0,0,20), on the z-axis twenty
- ; units in front of the screen. You can use the view
- ; menu to move the light source to (0,0,10), (0,0,40),
- ; or (0,0,100). You can also choose a "Parallel projection"
- ; where the light rays are parallel with each other and
- ; with the z-axis; this is like light from the sun, which
- ; is at an effectively infinite distance.
- ;
- ; You can think of projection from (0,0,20) as showing
- ; what you would see if your eye were at the point (0,0,20).
- ; (This is not entirely accurate, since then the size of
- ; the objects would shrink as you moved farther away; in fact,
- ; the image is adjusted to prevent this from happening.)
- ;
- ; The details of projection are beyond the scope of these
- ; tutorials. But you should try out the various possible
- ; views on this file.
-